<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Title</title>
		<style type="text/css">
			div {
				width: 200px;
				height: 200px;
				background-color: red;
				padding: 10px;
				border: 10px solid #000;
				margin: 10px;
			}
		</style>
	</head>
	<body>
		<div></div>
		
		<script src="jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				//获取div的宽度
				// console.log($("div").css("width"));
				// $("div").css("width","400px");
				
				//直接获取到的是数字
				//就是获取的width的值
// 				console.log($("div").width());//width
// 				console.log($("div").innerWidth());//padding+width
// 				console.log($("div").outerWidth());//padding+width+border
// 				console.log($("div").outerWidth(true));//padding+width+border+margin
// 				$("div").width(400);

				//需要获取页面可视区的宽度和高度
				$(window).resize(function(){
					console.log($(window).width());
					console.log($(window).height());
				});
			});
		</script>
	</body>
</html>